package trip;

import dao.*;

public class Factory {
	private static CompanyDAO company = null;
	private static Person_tripDAO person_trip = null;
	private static PersonDAO person = null;
	private static Route_stopsDAO route_stops = null;
	private static RouteDAO route = null;
	private static StopDAO stop = null;
	private static Time_tableDAO time_table = null;
	private static TripDAO trip = null;
	private static Factory instance = null;

	public static synchronized Factory getInstance() {
		if (instance == null) {
			instance = new Factory();
		}
		return instance;
	}
	
	public CompanyDAO getCompanyDAO() {
		if (company == null) {
			company = new CompanyDAOImpl(Company.class);
		}
		return company;
	}

	public Person_tripDAO getPerson_tripDAO() {
		if (person_trip == null) {
			person_trip = new Person_tripDAOImpl(Person_trip.class);
		}
		return person_trip;
	}

	public PersonDAO getPersonDAO() {
		if (person == null) {
			person = new PersonDAOImpl(Person.class);
		}
		return person;
	}

	public Route_stopsDAO getRoute_stopsDAO() {
		if (route_stops == null) {
			route_stops = new Route_stopsDAOImpl(Route_stops.class);
		}
		return route_stops;
	}

	public RouteDAO getRouteDAO() {
		if (route == null) {
			route = new RouteDAOImpl(Route.class);
		}
		return route;
	}
	
	public StopDAO getStopDAO() {
		if (stop == null) {
			stop = new StopDAOImpl(Stop.class);
		}
		return stop;
	}

	public Time_tableDAO getTime_tableDAO() {
		if (time_table == null) {
			time_table = new Time_tableDAOImpl(Time_table.class);
		}
		return time_table;
	}

	public TripDAO getTripDAO() {
		if (trip == null) {
			trip = new TripDAOImpl(Trip.class);
		}
		return trip;
	}
}